
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>选择设备</title>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <link rel="stylesheet" href="/lims/css/eleTree.css">
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/common.js?v=20190726" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019080918:09" type="text/javascript" charset="utf-8"></script>
    <style>
        .mbox{
            padding: 8px;
        }
    </style>
</head>
<body>

<div class="mbox">
    <div class="layui-card">
        <div class="layui-card-body" style="padding-left: 6px;">
            <div class="layui-form demoTable" style="display: inline-block;position: absolute;margin-top: 20px;">
                <div class="layui-form-item">
                    <div class="layui-inline" style="margin-top: -28px; margin-left: 50px;">
                        <label  class="layui-form-label" style="width: 86px;margin-top: 9px;">查询字段</label>
                        <div class="layui-input-inline" style="height: 27px;margin-top: 6px;" >
                            <select class="layui-select"  lay-filter="cloum" name="cloum" id="cloum" autocomplete="off" style="margin-top: -5px">
                                <option placeholder="请选择"></option>
                                <option value="EQUIP_NO">设备编码</option>
                                <option value="EQUIP_NAME">设备名称</option>
                                <option value="CODE_TYEP_NAME">设备状况</option>
                                <option value="MODEL_NO">型号</option>
                                <option value="SPEC">规格</option>
                                <option value="MANUFACTURER">生产厂家</option>
                                <option value="SUPPLIER">供应商</option>
                                <option value="PROPERTY_CODE">产权归属</option>
                                <option value="FACTORY_NO">出厂编号</option>
                            </select>
                        </div>
                        <div class=" layui-input-inline"  style="width: 150px;padding-top:5px;box-sizing: border-box">
                            <input type="text" name="price_max" id="fieldVal" placeholder="请输入" autocomplete="off" class="layui-input" style="margin-top: 1px;width:180px;">
                        </div>
                        <div class="layui-input-inline" style="width: 55px;margin-left: 38px">
                            <button id="search" class="layui-btn layui-btn-sm" data-type="reload" lay-event="serch"  style="height: 35px;line-height: 35px;margin-top:8px;width: 70px;">搜索</button>
                        </div>
                    </div>
                </div>
            </div>
            <table id="Settlement" lay-filter="Settlement" lay-data="{id: 'Settlement'}" style="margin-top:50px"></table>
        </div>
    </div>
</div>


<script>
    var equipId;   //复选框的id
    var equipStatusCode;
    var factoryNo;
    var equipNo;
    var treeid = parent.equippenter    //下拉树的id
    var deptId=parent.deptId;
    debugger
    var typedata  //定义的时数据表格的长度
    layui.use(['table','form'], function(){
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var tableObj=table.render({
            elem: '#Settlement'
            ,data:[],
            url : '/equipment/showEqip?',
            where:{
                equipTypeId:treeid,
                deptId:deptId
            }
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['prev', 'page', 'next',  'skip','count','limit',]//自定义分页布局
                ,limits:[5,10,15,20,25,30,35,40,45,50]
                ,first: false //不显示首页
                ,last: false //不显示尾页
            } //开启分页
            ,toolbar:'#toolbar'
            ,cols: [[ //表头
                {type: 'checkbox' }
                ,{field: 'equipNo', title: '设备编码'}
                ,{field: 'equipName', title: '设备名称', sort: true}
                ,{field: 'equipStatuasId', title: '设备状态'}
                ,{field:'equipStatusCode',hide:true}
                ,{field: 'modelNo', title: '型号'}
                ,{field: 'spec', title: '规格'}
                ,{field: 'manufacturer', title: '生产厂家'}
                ,{field: 'supplier', title: '供应商'}
                ,{field: 'propertyId', title: '产权归属'}
                ,{field: 'factoryNo', title: '出场编号'}
            ]]
            ,page: true
            ,done:function(res){
                if(res.msg=="查询无数据"){
                    $('.layui-table-page').hide()
                }
                form.render();
            }
        });

        //监听复选框事件
        table.on('checkbox(Settlement)', function(obj){
            //
                console.log(obj)
                equipId = obj.data.equipId
                console.log(equipId)
                equipStatusCode = obj.data.equipStatusCode
                factoryNo=obj.data.factoryNo
                equipNo=obj.data.equipNo
        });




        //监听行单击事件（双击事件为：rowDouble）
        var data=layui.table.checkStatus('Settlement').data;
        typedata= data.length


        /*  ----------搜索------*/
        $('#search').click(function(){
            var sele =$('#cloum').val()
            var inp = $('#fieldVal').val()
            if(sele==""&&inp==""){
                tableObj.reload({
                    url:'/equipment/selectEquipByField'
                    ,page:true,
                    equipTypeId:treeid
                })
            }else{
                tableObj.reload({
                    url:'/equipment/selectEquipByField'
                    ,page:true,
                    where:{
                        fieldName:sele,
                        fieldValue:inp,
                        equipTypeId:treeid
                    }
                })
            }
        })
        //回车实现搜索
        //下面方法兼容谷歌，火狐，ie:
        document.onkeydown = function (e) {
            var theEvent = window.event || e;
            var code = theEvent.keyCode || theEvent.which;
            if (code == 13) {
                $('#search').click();
            }
        };




    });


</script>



</body>
</html>